package dao

import (
	"fmt"
	"permange/models"
)
//通过gorm对数据库进行增删改添操作
func Selectemployee() ([]models.Employee, error){
	var Employee []models.Employee
	err := db.Table("employee").Order("eid ASC").Find(&Employee).Error//查询所有数据并按照升序输出
	fmt.Println(Employee)
	return Employee ,err
}
func Selectemploy_e(eid string) ([]models.Employee,error){
	var Employee []models.Employee
	err := db.Table("employee").Where("eid = ?",eid).Find(&Employee).Error//查询所有数据并按照升序输出
	return  Employee, err
}
func Addemployee(employee models.Employee) error {
	err := db.Table("employee").Create(&employee).Error//插入一行从前端发送过来的数据并且向数据库里添加新的元组
	return err
}
func Updateemployee(employee models.Employee) error{
	err := db.Table("employee").Where("eid = ?",employee.Eid).Updates(&employee).Error//根据前端传来的数据选择与其车牌号一致的元组进行更改
	return err
}
func Deleteemployee(id string)  error {
	err := db.Table("employee").Where("eid = ?",id).Delete(models.Employee{}).Error//根据前端输入的id进行删除
	return err
}
